<template>
  <!-- 调试导航栏 -->
  <nav v-if="true">
    <div class="navigator">导航栏，仅调试时使用</div>
    <router-link to="/">Home</router-link><span> | </span>
    <router-link to="/login">Login</router-link><span> | </span>
    <router-link to="/register">Register</router-link><span> | </span>
    <router-link to="/changepwd">Change-pwd</router-link><span> | </span>
    <router-link to="/account/info">account-info</router-link><span> | </span>
    <router-link to="/account/star/scholar">star-scholar</router-link><span> | </span>
    <router-link to="/account/star/paper">star-paper</router-link><span> | </span>
    <router-link to="/admin">Admin-home</router-link><span> | </span>
    <router-link to="/admin/reviewclaim">Admin-reviewclaim</router-link>
    <router-link to="/venue">Venue</router-link><span> | </span>
    <span class="identify">{{
    this.$store.state.hasLogin ?
    this.$store.state.user.user_name + '(' + this.$store.state.user.email + ')':
    "游客" }}</span>
    <el-button type="info" plain @click="logout">登出</el-button>
  </nav>

  <!-- 导航栏 -->
  <navigator-view></navigator-view>

  <router-view/>
</template>

<script>
import { req_logout } from '@/api'
import { response2ElMessage } from '@/utils/response-utils'
import NavigatorView from '@/components/navigator-view/NavigatorView.vue'

export default {
  components: { NavigatorView },
  data() {
    return {
      
    }
  },
  methods: {
    async logout() {
      let response = await req_logout()
      let data = response.data
      if (data['errno'] === 1) {
        this.$store.commit('clearUser')
      }
      response2ElMessage(response)
    }
  },
  created() {

  },
  mounted() {
    this.$store.dispatch('userGet')
  }
}
</script>

<style>
/* 全局 */
#app {

}

/* 调试导航栏 */
nav {
  padding: 30px;
  background-color: var(--back-color);
}

nav a {
  font-weight: bold;
  color: var(--text-color);
}

nav a.router-link-exact-active {
  color: #42b983;
}

.navigator,
.identify{
  color: var(--text-color); /* 全部字设置为白色 */
}
</style>
